﻿<!-- saved from url=(0016)http://localhost -->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" /> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />    
	<title>Markdown Editing</title>      
</head>
<body>
    <b>Place holder</b>
    
    <script src="scripts/to-markdown.js"></script>
    
    <!--<script src="scripts/turndown.browser.umd.js"></script> -->
    <!--<script src="scripts/bluebird.core.min.js"></script>-->
    <!--<script src="scripts/upndown.bundle.min.js"></script>-->
<script>
       
       
       
        
        function htmltomarkdown(html) {
            // to-markdown
            try {
                return toMarkdown(html);
            } catch (ex) {
                return null;
            }

            // upndown - lots of issues with parsing inline elements wrong 
            // var und = new upndown();
            // var markdown = null;
            // und.convert(html, function(err, convertedMarkdown) {
            //     if (err) {
            //         window.resultMarkdown = "ERROR: " + err.message;
            //     } else {
            //         window.resultMarkdown = convertedMarkdown;
            //     }
            // });
            
           return markdown;
                
            
            // turndown - doesn't work worth a crap if HTML contains non-parsable raw HTML       
            // try {
            //    var turndownService = new TurndownService({
            //        headingStyle: 'atx',
            //        codeBlockStyle: 'fenced',
            //        fence: '```',
            //        hr: '---',
            //        emDelimiter: '*',
            //        strongDelimiter: '**',
            //        defaultReplacement: function (innerHtml, node) {                        
            //            return node.isBlock ? '\n\n' + node.innerText + '\n\n' : node.innerText;
            //        }   
            //    });
            //    return turndownService.turndown(html);
            // }
            // catch(ex)
            // {
            //    alert("Markdown Conversion failed: " + ex.message);
            //    return null;
            // }
        }
    </script>

</body>
</html>